package org.example.methodreference;

import java.util.function.BiFunction;

public class Java8MethodReference1c {
    public static void main(String[] args) {
        String result1 = payTwoArgument(1, 2, new BiFunction<Integer, Integer, String>() {
            @Override
            public String apply(Integer integer, Integer integer2) {
                return IntegerUtils.join(integer, integer2);
            }
        });
        System.err.println("result1=" + result1);

        String result2 = payTwoArgument(1,2,(a,b) -> IntegerUtils.join(a,b));
        System.err.println("result2=" + result2);

        String result3 = payTwoArgument(1,2,IntegerUtils::join);
        System.err.println("result3=" + result3);
    }
    private static <R> R payTwoArgument(Integer i1,Integer i2,BiFunction<Integer,Integer,R> func){
        return func.apply(i1,i2);
    }
}
class IntegerUtils{
    public static String join(Integer a,Integer b){
        return String.valueOf(a + b);
    }
}
